package com.gitee.huanminabc.utils_tools.class_extend.javassist;


import java.util.HashMap;
import java.util.Map;

public class AopFactory {
   public static Map<String, ClassAspect> aspects;
   static {
       aspects=new HashMap<>();
   }
    public static void addAspect(ClassAspect aspect){
       //判断是否已经存在
        if(aspects.containsKey(aspect.getClass().getName())){
            throw new RuntimeException("AopFactory->代理类已经存在:"+aspect.getClass().getName());
        }
        aspects.put(aspect.getClass().getName(),aspect);
    }

    /**
     * 获取代理类
     * @param aspectKey 代理类的key：代理类的全类名
     * @return
     */
    public static ClassAspect getAspect(String aspectKey){
        return aspects.get(aspectKey);
    }
}
